using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class PackagerWindows : PackagerBase
{
    public override void BuildPlayer(bool export = true)
    {
        BuildAssetBundle();
        CreateStandalone();
    }
    
    private void CreateStandalone()
    {
        string[] levels = packagerRules.startupScenes;
        string packagePath = $"{PreparePackageDir()}/{packagerRules.appName}{GetAppExtension()}";
        EditorUserBuildSettings.development = Packager.DEVELOPMENT;
        EditorUserBuildSettings.connectProfiler = Packager.DEVELOPMENT;

        // PlayerSettings.SetAdditionalIl2CppArgs(USE_MONO ? "" : "--compiler-flags=\"/d2FH4-\"");
        
        // 编译类型
        PlayerSettings.SetIl2CppCompilerConfiguration(
            BuildTargetGroup.Standalone, 
            Packager.DEVELOPMENT ? 
                Il2CppCompilerConfiguration.Debug : 
                Il2CppCompilerConfiguration.Release);
        
        // 设置 ScriptingBackend（脚本后处理）
        PlayerSettings.SetScriptingBackend(
            BuildTargetGroup.Standalone, 
            Packager.USE_MONO ? 
                ScriptingImplementation.Mono2x : 
                ScriptingImplementation.IL2CPP);
        
        // 打包exe
        BuildPipeline.BuildPlayer(levels, 
            packagePath, 
            BuildTarget.StandaloneWindows64, 
            Packager.DEVELOPMENT ? 
                BuildOptions.Development : 
                BuildOptions.None);
    }
}
